package com.ssy.lingxi.scheduler.api.feign;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.scheduler.api.model.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;
import java.util.List;

/**
 * 定时任务OpenFeign接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-13
 */
@FeignClient(name = "scheduler-service")
public interface ScheduleTaskFeign {
    /**
     * 创建定时任务
     * @param taskVO 接口参数
     * @return 定时任务的Id
     */
    @RequestMapping(value = "/schedule/task/create", method = RequestMethod.POST)
    Wrapper<Long> createScheduleTask(@RequestBody @Valid ScheduleTaskVO taskVO);

    /**
     * 创建永久任务
     * @param taskVO 接口参数
     * @return 定时任务的Id
     */
    @RequestMapping(value = "/schedule/task/create/permanent", method = RequestMethod.POST)
    Wrapper<Long> createPermanentTask(@RequestBody @Valid PermanentTaskVO taskVO);

    /**
     * 查询定时任务信息列表
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/schedule/task/list", method = RequestMethod.POST)
    Wrapper<List<ScheduleTaskDefinitionVO>> listScheduleTask(@RequestBody @Valid ScheduleTaskQueryVO queryVO);

    /**
     * 修改任务的启动时间
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/schedule/task/time/update", method = RequestMethod.POST)
    Wrapper<Void> updateScheduleTaskExecTime(@RequestBody @Valid ScheduleTaskUpdateExecTimeVO updateVO);

    /**
     * 删除任务
     * @param idVO 接口参数
     * @return 通知结果
     */
    @RequestMapping(value = "/schedule/task/delete", method = RequestMethod.POST)
    Wrapper<Void> deleteScheduleTask(@RequestBody @Valid ScheduleTaskIdVO idVO);
}

